package com.dgut.courses_selecting_sys.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.dgut.courses_selecting_sys.entity.Notice;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author yuec
 * @since 2020-09-09
 */
@Repository
public interface NoticeMapper extends BaseMapper<Notice> {

    @Select(" select * from sys_notice where deleted=0 and notice_id in \n" +
            "(select notice_id from sys_dept_notice dn where dept_id=#{deptId}) order by notice_id desc limit 10")
    List<Notice> selectListlistNewTen(@Param("deptId")int deptId);

    @Select(" select * from sys_notice where deleted=0 and  notice_id in \n" +
            " (select notice_id from sys_dept_notice dn where dept_id=#{deptId} and gmt_create>=#{date}) order by notice_id desc ")
    List<Notice> selectListlistPassMonth(@Param("deptId") int deptId, @Param("date") Date date);

    @Select("select * from sys_notice where deleted=0 and  notice_id in (\n" +
            " (select notice_id from sys_dept_notice dn where dn.dept_id=#{deptId}) \n" +
            " ) order by notice_id desc")
    List<Notice> selectListlistAllNotice(@Param("deptId")Integer deptId);

    @Select("select * from sys_notice order by gmt_create desc limit 1")
    int selectLastAdd();
}
